from bokeh.plotting import figure, curdoc
from bokeh.models import ColumnDataSource
from bokeh.layouts import column
from bokeh.models.widgets import Slider

# 创建数据
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]

# 创建数据源
source = ColumnDataSource(data=dict(x=x, y=y))

# 创建图表
p = figure(title="Interactive Plot", x_axis_label='x', y_axis_label='y')
p.line('x', 'y', source=source, line_width=2)

# 创建滑块
slider = Slider(start=1, end=10, value=1, step=1, title="Multiplier")

# 定义回调函数
def update_data(attrname, old, new):
    multiplier = slider.value
    new_y = [i * multiplier for i in y]
    source.data = dict(x=x, y=new_y)

# 绑定回调函数
slider.on_change('value', update_data)

# 将图表和滑块放入布局
layout = column(slider, p)

# 添加到文档
curdoc().add_root(layout)